#include<stdio.h>
#include<string.h>

# define INF INT_MAX
#define MAXVEX 1000

visited[MAXVEX] = {0};

typedef char VertexType[10];

typedef char edgenode{
    int adjvex;
    int weight;
    struct edgenode *nextarc;
}ArcNode;

typedef struct vexnode{
    VertexType data;
    ArcNode *firstarc;
}VHeadNode;

typedef atruct{
    int n,e;
    VHeadNode adjlist [MAXVEX];
}ALGraph;

void CreateGraph(ALGraph *&G,int A[][MAXVEX],int n,int e){
    int i,j;
    ArcNode *p;
    G = (ALGraph *)malloc(sizeof(ALGraph));

    G->n = n;
    G->e = e;
    for(i=0;i<G->n;i++)
        G->adjlist[i].firstarc = NULL;
    for(i=0;i<G->n;i++)
        for(j=G->n-1;j>=0;j--)
            if(A[i][j] > 0 && A[i][j] < INF){
                p = (ArcNode *p)malloc(sizeof(ArcNode));
                p->adjvex = j;
                p->weight = A[i][j];
                p->nextarc = G->adjlist[i].firstarc;
                G->adjlist[i].firstarc = p;
            }
}

void DFS(AdjGraph *G,int V){
    int w;
    ArcNode *p;
    printf("%d",v);
    visited[V] = 1;
    p = G->adjlist[V].firstarc;
    while(p != NULL){
        w = p->adjvex;
        if(visited[w] == 0)
            DFS(G,w);
            p = p->nextarc;
    }
}

int main(){

}